<?php
/* SVN FILE: $Id: edit.ctp 38 2009-11-02 02:15:06Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-11-02 02:15:06 +0000 (Mon, 02 Nov 2009) $
 * $Revision: 38 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/views/assessments/edit.ctp $
 */
  if (!empty($this->data)) 
  {
?>
<p>
<dl>
  <dt>Assignment</dt>
  <dd><?= $this->data['Assignment']['name'] ?></dd>

  <dt>File</dt>
  <dd><?= $html->link($this->data['Submission']['file_name'],'/submissions/download/' . $this->data['Submission']['id']) ?> (Click to download)</dd>
  
  <dt>Type</dt>
  <dd><?= $this->data['Submission']['file_type'] ?></dd>
  
  <dt>Size</dt>
  <dd><?= number_format($this->data['Submission']['file_size'] / 1024,1) . 'kb' ?></dd>

  <dt>Grading Option</dt>
  <dd><?= $this->data['GradingOption']['name'] ?></dd>

<?php
    if (!empty($this->data['Submission']['comments'])) 
    {
?>  
  <dt>Comments</dt>
  <dd><?= $this->data['Submission']['comments'] ?>&nbsp;</dd>
<?php
    }
?>
</dl>
</p>
<h4>Test Cases</h4>
<p>Design and run a series of test cases. Ensure that you provide a thorough description of your test conditions and results.
To receive a top score from the submission author, be sure that your test cases cover all requirements.</p>
<table width="100%">
<?php
  echo $html->tableHeaders(array('#','Name','Description','Results','Outcome','Action'));
    
  if (count($test_cases) > 0)
  {
    foreach ($test_cases as $test_case)
    {
      $action = $html->link('Edit','/assessment_test_cases/edit/' . $test_case['at']['id']) . ' / ' .
                $html->link('Delete','/assessment_test_cases/delete/' . $test_case['at']['id'] . '/' . $this->data['Assessment']['id'],null,'Are you sure you want to delete this test case result?');
                
      echo $html->tableCells(array($test_case['t']['id'],
                                   $test_case['t']['name'],
                                   $test_case['t']['description'],
                                   $test_case['at']['results'],
                                   $test_case['r']['name'],
                                   $action),
                             null,
                             array('class' => 'altrow'));
    }        
  }
  else
  {
?>
<tr><td colspan="6">No Test Cases Found.</td></tr>
<?php
  }
?>
</table>
<p><?=count($test_cases)?> Completed Test Cases (minimum 5 required). <?=$html->link('Add','/assessment_test_cases/add/' . $this->data['Assessment']['id']) ?> a test case to this assessment.</p>
<br>
<h4>Submission Qualities</h4>
<p>Indicate your level of agreement with the following statements regarding this submission:</p>
<table>
<?php
    echo $html->tableHeaders(array('Quality','Your Response','Your Comments'));

    $all_qualities = true;
    
    foreach ($qualities as $quality)
    {
      if (empty($quality['l']['name']))
      {
        $response = $html->link('Respond','/assessment_quality_attributes/edit/' . $quality['aq']['id']);
        $all_qualities = false;
      }
      else
      {
        $response = $quality['l']['name'] . ' (' . $html->link('Edit','/assessment_quality_attributes/edit/' . $quality['aq']['id']) . ')';
      }
      
      $comments = $quality['aq']['comments'];
      
      if (empty($comments))
      {
        $comments = '(None)';
      }
             
      echo $html->tableCells(array($quality['q']['name'],$response,$comments),null,array('class' => 'altrow'));       
    }
?>
</table>
<?php

    if (count($test_cases) >= 5 && $all_qualities)
    {      
      echo $form->create('Assessment');
      echo $form->input('id');
      echo $form->input('mins_est',array('label' => 'For course improvement purposes, please estimate the number of <em>minutes</em> you spent preparing this assessment:',
	                                 'maxLength' => 2));
      echo $form->end('Submit');
    }
  }
?>
<p>Return to <?=$html->link('your assessments',"/assessments/index/{$this->data['Assignment']['course_id']}") ?> (without submitting)</p>
<br>